import 'package:flutter/material.dart';
import 'package:flutterdemo/common/calc.dart';
import 'package:flutterdemo/components/my_appbar.dart';
import 'package:flutterdemo/components/none.dart';

class Search extends StatefulWidget {
  Search({Key? key}) : super(key: key);

  @override
  _SearchState createState() => _SearchState();
}

class _SearchState extends State<Search> with TickerProviderStateMixin {
  TabController? _tabController;

  // 顶部搜索栏
  Widget _searchWidget() {
    return Padding(
        padding: EdgeInsets.all(Calc.width(20)),
        child: Row(
          children: [
            Expanded(
              flex: 1,
              child: Container(
              child: Center(
                child: TextField(
                    onSubmitted: (e) {},
                    autofocus: true,
                    textInputAction: TextInputAction.search,
                    decoration: InputDecoration(
                      hintText: "搜一搜",
                      isCollapsed: true,
                      prefixIcon: Icon(Icons.search),
                      contentPadding: EdgeInsets.all(5),
                      border: InputBorder.none,
                    )),
              ),
              height: 30,
              decoration: BoxDecoration(
                  color: Colors.white,
                  borderRadius:
                      BorderRadius.all(Radius.circular(Calc.width(10)))),
            ),),
            SizedBox(width: Calc.width(20),),
            InkWell(
              onTap: (){
                Navigator.pop(context);
              },
              child: Text("取消",style: TextStyle(color: Colors.blueAccent),),
            )
          ],
        ));
  }
  
  // 内容区域
  Widget _contentW(){
    return Scaffold(
      backgroundColor: Color.fromRGBO(233, 233, 233, 1),
      resizeToAvoidBottomInset: false,
      appBar: MyAppBar().getAppBar("123",
        toolbarHeight: 0,
        bottom: TabBar(
          labelColor: Theme.of(context).accentColor,
          isScrollable: true,
          unselectedLabelColor: Colors.black,
          indicatorSize:TabBarIndicatorSize.label,
          controller: _tabController,
          tabs: [
            Tab(text: "全部",),
            Tab(text: "好友",),
            Tab(text: "商品",),
            Tab(text: "消息",),
            Tab(text: "移门",),
          ],
        ),
      ),
      body: TabBarView(
        controller: _tabController,
        children: [
        None(),
        None(),
        None(),
        None(),
        None(),
      ],),
    );
  }



  @override
  Widget build(BuildContext context) {
    Calc.init(context);
    return Scaffold(
      resizeToAvoidBottomInset: false,
      appBar: MyAppBar().getAppBar("", toolbarHeight: 0, elevation: 0),
      backgroundColor: Color.fromRGBO(233, 233, 233, 1),
      body: Column(
        children: [
          _searchWidget(),
          Expanded(child: _contentW(),flex: 1,)
        ],
      ),
    );
  }

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _tabController = TabController(vsync: this,length: 5);
  }
}
